package com.hubstc.book_borrow.mapper;

import com.hubstc.book_borrow.pojo.Reader;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ReaderMapper {

    // 查询读者id判断是否有人注册
    @Select("select * from reader where readerId=#{readerId}")
    Reader finByReaderId(String readerId);

    //添加用户信息
    @Insert("insert into reader (readerId,password,reader_per) values (#{readerId},#{password},#{readerPer});")
    void addReader(String readerId,String password,int readerPer);

    //更新用户信息
    @Update("update reader set name=#{name},sex=#{sex},major=#{major},phone=#{phone} where readerId=#{readerId}")
    void updateReader(Reader reader);

    //更新用户密码
    @Update("update reader set password = #{newPwd} where readerId=#{readerId};")
    void updatePwd(String readerId,String newPwd);
}
